home *** CD-ROM | disk | FTP | other *** search
/ WINMX Assorted Textfiles / Ebooks.tar / Text - Tech - Hacking - Softice - Beginner Tutorial (TXT).zip / SI_BEG.TXT < prev   
Text File  |  1997-12-17  |  13KB  |  286 lines

  1.  
  2. :::::::::::::::::::::  m E X / c 4 N  T U T O R I A L  D I V I S I O N ::::::::::::::::::::::::::
  3.  
  4. Tutor      : CoRN2
  5. Editor     : Notepad (fullscreen wit' wordwrap on)
  6. Audience   : Beginners an' Newbies :)
  7. Greets     : All members of C4N/mEx'97... and everyone else I know :)
  8. Target     : SoftIce for Newbies, r4
  9. Rev Date   : 17/12/97
  10.  
  11. Check out http://mex97.home.ml.org for all your cracking needs!!
  12.  
  13.  
  14. Foreword
  15. -=-=-=-=
  16. Hey there, wow, I'm on revision 4 of this tutorial now! Thanks to everybody who has written to me, especially those with helpful suggestions. This update is therefore due to public demand ;) Hopefully it will help all of you newbies out there, maybe not... ah well... ;)
  17.  
  18. Introduction
  19. -=-=-=-=-=-=
  20. Everybody asks the question, 'which debugger should I use?' The answer is usually SoftIce... The second question is 'how do I use SoftIce!?!' This tutorial should hopefully cover the basic aspects of using SoftIce for our 'evil' needs!! ;)
  21.  
  22. I'm going to assume that you're using SoftIce/Win95 v3.0 or later. Once installed, SoftIce lives behind win until you need it... now the fun bit...
  23.  
  24. To access SoftIce you simply press <CTRL-D> unless of course you've changed this hotkey.
  25.  
  26.  
  27. EXTERNALS
  28. -=-=-=-=-
  29. This seems to plague almost everyone who still remembers the day that their fingers first traced the sacred CTRL-D combination. My first question was ( in #cracking ) as far as I remember, why can't I breakpoint on GETDLGITEMTEXT ( or similar functions )
  30.  
  31. It took me a week until someone answered ( c4n rocks! plug plug ) its really quite easy. I think this is covered in the c4n-mex faq also:
  32.  
  33. Load up the file WINICE.DAT in your favourite text-editor ( notepad will do if you haven't got one :P ) and find the lines near the end of the file that start with:
  34.  
  35. ;exp=c:\windows_directory\kernel32.dll
  36. ;exp=c:\windows_directory\user32.dll
  37.  
  38. If you remove the semi-colon ';' from the start of the above two lines, most of the
  39. calls with be available- if not just remove them from other lines. Save
  40. WINICE.DAT and restart windows/softice, easy eh?
  41.  
  42. You can also use the symbol loader to edit the these settings ( thanks _[mP] :) )
  43.  
  44. While we're on the subject of WINICE.DAT, I thought you should know the more useful *default* keyboard mappings for SI...
  45.  
  46. F1  - Help
  47. F2  - Toggle Register Window
  48. F5  - Drop back to Windows
  49. F8  - Trace To Next Instruction (will dive into all CALLS)
  50. F10 - Step To Next Instruction (executes and steps over CALLS)
  51. F12 - Run up until the next RETurn instruction
  52.  
  53. There are a shitload more, but these are the more useful ones I would use....
  54.  
  55. Now to the fun stuff...
  56.  
  57.  
  58. I'VE PRESSED CTRL-D, WTF IS ALL THIS STUFF!!!?!??!
  59. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  60. Although maybe daunting at first, its all pretty simple. You really do need to have a rough idea about ASM for me to be able to explain this properly. If not, get my tut, 'ASM For Crackers' (PLUG! PLUG!) from the mExeLITE'97 homepage. It should cover the basics.
  61.  
  62. A BIT ABOUT THE SCREEN YOU'RE GAWPING AT
  63. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  64. Before we continue, you should check that you have four (count 'em) seperate boxes on your screen, if not you should note that they can be hidden/shown with any one of the following commands:
  65.  
  66. WR -- Show/Hide Register Window            |
  67. WD -- Show/Hide Data Window            } including a number after the command
  68. WC -- Show/Hide Code Window               | allows you to set how many lines are used.
  69.  
  70. These are the most important, but you'll find there are also other windows that you can toggle, including watches etc... but this will server the purposes of our tut.
  71.  
  72. These windows can be mucked about with individually, each is independently scrollable, using the following keyboard combinations: 
  73.  
  74. <CTRL-UP/DOWN/PGUP/PGDN>  Scrolls the CODE Window
  75. <SHIFT-UP/DOWN/PGUP/PGDN> Scrolls your INPUT (command) Window
  76. <ALT-UP/DOWN/PGUP/PGDN>   Scrolls the DATA Window 
  77.  
  78. A bit of a cool trick involves the DATA window, some really lame protection schemes end up placing the correct 'serial number' a couple of bytes away from your input, by simply scrolling your data window, it is sometimes possible to discover this serial and save yourself a shitload of work! --pretty cool huh?
  79.  
  80. Now back to your tut.
  81.  
  82. -=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=
  83.  
  84. Ok. Now you know what registers are, and hopefully what a chunk of assembly looks like. 
  85.  
  86. The top three lines of the screen are dedicated to your computers registers, and their contents. This is fairly self explanitory. 
  87.  
  88. EAX=whatever, EBX=whatever, and so on.
  89.  
  90. The second line at the far right contains 8 letters, these are your flags. Capital blue letters indicate that the flag is set, the flags are:
  91.  
  92.     O D I S Z A P C 
  93.         | | | | | | | |
  94.         | | | | | | | +------- Carry Flag
  95.     | | | | | | +--------- Parity Flag
  96.     | | | | | +----------- Auxiliary Carry Flag
  97.     | | | | +------------- Zero Flag ( VERY USEFUL! )
  98.     | | | +--------------- Sign Flag
  99.     | | +----------------- Interrupt Flag
  100.     | +------------------- Direction Flag
  101.     +--------------------- Overflow Flag
  102.  
  103. To be honest the only one I've ever looked at while cracking, is the Zero Flag ( its looked for JZ/JNZ/JE/JNE commands )
  104.  
  105. Next we have another window underneath, this is your data window. It shows the value of any memory address you might need. As an example, type: d F9D2B    --this shows the bytes at that address.
  106.  
  107. 'd' is your display memory command.
  108.  
  109. Following this we have the code window. This contains the part of the program that we're looking at. Firstly you have the segment:offset of the code, then the opcode, then the asm commands we all love :)
  110. ( NB you may have to type 'CODE ON' in order to see the opcode )
  111.  
  112. And finally at the bottom is your input/information window. In other words the bit you use to talk to SoftIce, and hears its' response.
  113.  
  114.  
  115. BREAKPOINTS IN GENERAL
  116. -=-=-=-=-=-=-=-=-=-=-=
  117. Breakpoints are a useful (if not essential) addition to a crackers arsenal. Without them, life would be a little bit harder for us, and easier for the protectionists. Breakpoints are simply that, points at which the program will break, due to a condition being met ( we'll look at this in detail now )
  118.  
  119. BREAKPOINT ON EXECUTE
  120. -=-=-=-=-=-=-=-=-=-=-
  121. SYNTAX: bpx <api function name>
  122.  
  123. The main problem with cracking... umm.. sorry debugging ( heh! ) is to find yourself an entry point into the program. The easiest, and most effective way to begin is with breakpoints.
  124.  
  125. Basically all you need to do is to tell SoftIce when to 'break' into the program so you can see whats happening. The type of breakpoint that you would use depends upon the type of program you're trying to 'debug' ;)
  126.  
  127. To show this we'll take an example:
  128.  
  129. 1. Switch to SoftIce ( CTRL-D ), and type 'bpx GetLocalTime'
  130. 2. The prompt should return, switch back to win ( CTRL-D )
  131. 3. Double click on the win95 system clock ( usually on your taskbar )
  132.  
  133. SoftIce should now pop up, at the start of the call to 'GetLocalTime', if you press F11 you will return to the part of the code that called the function. 
  134.  
  135. Another function call to breakpoint on is useful when cracking serial number protections is 'GetWindowTexta' or 'GetDlgItemTexta'. This is done in exactly the same way. 
  136.  
  137. 1. Click your StartButton ( good old MS :P ) and click upon the 'RUN'
  138.    button.
  139. 2. Type in any old crap, ie. 'lalalalalalalalalaa' DON'T PRESS ENTER
  140. 3. Switch to SoftIce. ( CTRL-D )
  141. 4. Type: BPX GetWindowTextA
  142. 5. Switch back to win, now press ENTER
  143.  
  144. SoftIce pops up at the Start of 'GetWindowTexta', so again press F11 to return to the calling code. GetDlgItemTexta isn't used as much in my experience, but worth trying if nothing happens on GetWindowTexta.
  145.  
  146. SEARCHING MEMORY.
  147. -=-=-=-=-=-=-=-=-
  148. SYNTAX: s <start> l <finish> '<string>'
  149.  
  150. Simple one this. Say you've entered your registration info, and you're lost in the code somewhere, to help yourself along you can search in memory for your info ( WOW! ;) )
  151.  
  152. When searching you want to look for it everywhere, so I mainly use:
  153.  
  154.    s 0 l ffffffff 'mystring'
  155.  
  156. Once found you'll get a nice prompt telling you where in memory it is, and the data window changes to that address.
  157. To Search again just type: s
  158.  
  159. This will keep searching, beware though, that in my experience, any strings found around the 80000000+ and C0000000+ areas are either duplicates or bits of shite floating about due to Win95's amazing management of your ram :) aren't you glad you 'bought' it?!
  160.  
  161. BREAKPOINTING ON MEMORY ACCESS
  162. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  163. SYNTAX: BPM <address> R/W
  164.  
  165. This is usually used in conjunction with the step above, searching. Once you've found your string, what use is it to you???
  166.  
  167. Say through searching, I got the prompt:
  168.  
  169. Pattern Found at 0157:0009AC2D
  170.  
  171. ok, this tells us that my string was found at the location 0157:0009AC2D ( doh! ). So to get SoftIce to monitor this we'd use:
  172.  
  173. BPM 0157:0009AC2D
  174.  
  175. The R/W tells SoftICe whether to pop up on a read or write operation to that address. The default is RW ( read & write )
  176.  
  177.  
  178. BREAKPOINTING ON A RANGE OF MEMORY ACCESSES
  179. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  180. SYNTAX: BPR <start address> <end address> R/W
  181.  
  182. Sometimes a more useful function. Imagine for example, that you want to track a range of memory addresses, for example, a Username string, or Unlock Code.
  183.  
  184. Given the above example, if was to search for my username, 'mExeLITE'97 cracked bY CoRN2', and I'm told that it was found at 0157:00643345. If I wanted to keep an eye on the entire range of memory addresses taken by this string, I would use the syntax:
  185.  
  186. BPR 0157:00643345 0157:00643345+(Length of string in hex)
  187.  
  188. This will cause SI to popup whenever any part of the memory within this range is read from or written to.
  189.  
  190. Now we'll look at the additional breakpoint manipulators that'll stop you screaming at SI when it pops up hours after you've finished cracking.
  191.  
  192. LIST BREAKPOINTS
  193. -=-=-=-=-=-=-=-=
  194. SYNTAX: bl
  195.  
  196. Simply lists any defined breakpoints in the following format:
  197. NUM) BREAKPOINT_TYPE PARAMETERS COUNT
  198.  
  199. An example could be:
  200. 00) BPX #0028:09876543 C=01
  201.  
  202. This tells us that SoftIce will pop up when ever the instruction at address 0028:09876543 depending upon the number of times it has occured, specified by Count. In the above example, since C=01 SI will popup the first time that this occurs.
  203.  
  204.  
  205. CLEAR BREAKPOINT
  206. -=-=--=-=-=-=-=-
  207. SYNTAX: bc <breakpoint(s)>
  208.  
  209. This clears the specified breakpoint(s), for example:
  210.  
  211. BC 0      <-- Clears the breakpoint labelled 0
  212. BC 1,4    <-- Clears breakpoints labelled 1 and 4
  213. BC *       <-- Clears all breakpoints
  214.  
  215.  
  216. DISABLE BREAKPOINT
  217. -=-=-=-=-=-=-=-=-=
  218. SYNTAX: bd <breakpoint(s)>
  219.  
  220. Sometimes it'll be more beneficial (and or useful) to simply disable a breakpoint temporarily, rather than remove it completely. Again, for example:
  221.  
  222. BD 1,2,3,5  <-- Disables breakpoints labelled 1,2,3,5
  223. BD 1        <-- Disables breakpoint 1
  224. BD *        <-- Disables all breakpoints
  225.  
  226.  
  227. ENABLING BREAKPOINTS
  228. -=-=-=-=-=-=-=-=-=-=
  229. SYNTAX: be <breakpoint(s)>
  230.  
  231. Obviously, if you can disable breakpoints, then you're going to need to be able to enable them again. I'll not give you any more examples 'cos this follows exactly the syntax given above.
  232.  
  233.  
  234. SOFTICE & The Net (The Internet/The Information Super-Highway ARRGGH!)
  235. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  236. Some people ( not me yet ) have experienced a problem when cracking whilst logged on. This won't affect people who ( like me ) aren't lucky enough to get FREE LOCAL PHONE CALLS!! who have to pay úúú's for their phonebills... sorry.
  237.  
  238. Anyway, if you're logged on and you switch to SoftIce many people experience a loss in their connection ( mainly to IRC ) Apparently this is fixable by using the '/AWAY asuidsodj' command, but I dunno. Try it if you get stuck.
  239.  
  240.  
  241. FINAL WORD
  242. -=-=-=-=-=
  243. This tute should ( hopefully, unless I totally messed it up ) cover enough about SoftIce to allow the average newbie to get started. I know there is a shitload of stuff I haven't covered, there should be a more advanced tut arriving soon ( watch this space |     | ;) ) 
  244.  
  245. If there is anything you else think ppl need to know to get started, or anything you think should be added, just mail me at CoRN02@hotmail.com and tell me. I can be reached on EFNET, in #Cracking4Newbies most of the time... someone will be able to help anyway....
  246.  
  247. Hope this helps anyone who wants to learn's task easier... I could have done with this when I started. Good Luck!
  248.  
  249.  
  250. -- CoRN2 [mE'97/C4N]
  251.  
  252. :::::::::::::::::::::  m E X / c 4 N  T U T O R I A L  D I V I S I O N ::::::::::::::::::::::::::
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282. Heh, didn't think anyone would bother reading down here...... 
  283. YOU'VE FOUND THE SECRET PART OF THIS TUTE! Congratulations! :)
  284.  
  285. wow you've won a years supply of spam.
  286.